Release 10.1A: OpenEdge Development:
Progress 4GL Reference
COPY-LOB statement
Copies large object data between BLOBs, CLOBs, MEMPTRs, and LONGCHARs. It also copies large object data to and from the file system, and converts large object data to or from a specified code page.
Note: You cannot copy large object data between BLOBs and CLOBs directly. However, you can copy a BLOB or CLOB to a MEMPTR or LONGCHAR (which converts the data) and then copy the MEMPTR or LONGCHAR to the CLOB or BLOB, respectively.Syntax
[ OBJECT ]source-lobThe source object to be copied, which can be a MEMPTR or LONGCHAR variable, a BLOB or CLOB database or temp-table field, or a dynamic expression that resolves to a BLOB or CLOB database or temp-table field. The source object data at this location is copied to the specified target object or file.
FILEsource-filenameA character expression that specifies the name of a file containing the source object data to be copied. The object data in this source file is copied to the specified target object or file. You can specify an absolute or relative pathname.
Progress raises the ERROR condition if
source-filenameresolves to the Unknown value (?) or the source file cannot be read.STARTING ATnAn integer expression indicating a one-based offset position, in the source object or file, from which to start copying. The copy begins at offset 1, by default. Progress raises the ERROR condition if the specified offset position is less than 1, greater than the size of the object or file, or the Unknown value (
Note: Offsets are measured in bytes for binary data (BLOB or MEMPTR), and characters for character data (CLOB or LONGCHAR).?).FORlengthAn integer expression indicating the number of bytes or characters to copy from the source object or file starting at the specified offset position. Progress copies from the specified offset position to the end of the object or file, by default. Progress raises the ERROR condition if the specified length is less than 0, greater than the size of the object or file, or the Unknown value (
Note: Offsets are measured in bytes for binary data (BLOB or MEMPTR), and characters for character data (CLOB or LONGCHAR).?).[ OBJECT ]target-lobThe target object to receive the copy, which can be a MEMPTR or LONGCHAR variable, a BLOB or CLOB database or temp-table field, or a dynamic expression that resolves to a BLOB or CLOB database or temp-table field. The object data in the specified source object or file is copied to the target object.
If the specified target object does not yet exist, Progress either creates a BLOB or a CLOB, or allocates memory for a MEMPTR or a LONGCHAR. If the specified target object already exists, Progress deletes the object before the copy operation begins, by default. You can specify the OVERLAY AT
Note: Although Progress allocates memory for a target MEMPTR, you are responsible for freeing that memory.noption to overlay some portion of an existing target object.OVERLAY ATn[ TRIM ]An overlay position in the target object. Progress copies the source object or file to an existing BLOB, CLOB, MEMPTR, or LONGCHAR target starting at the given position. If the operation results in writing past the end of a target BLOB, CLOB, or LONGCHAR, Progress extends the target object as necessary. If the operation results in writing past the end of a target MEMPTR, Progress raises the ERROR condition.
If the target object does not yet exist, Progress raises the ERROR condition. If the specified overlay position is less than 1, greater than the size of the object, or the Unknown value (
?), Progress raises the ERROR condition.You can specify the TRIM option only if the target object is a BLOB or CLOB. In this case, Progress copies the source object or file to the existing target object and truncates any data remaining in the target object. If the target object is a MEMPTR or LONGCHAR, Progress ignores this option.
FILEtarget-filename[ APPEND ]A character expression that specifies the name of the target file to which the object data in the specified source object or file is copied. You can specify an absolute or relative pathname.
If the target file does not exist, Progress creates the file. If the target file exists, and you specify the
APPENDoption, Progress opens the file and appends the object data to the end of a file. If the target file exists, but you do not specify theAPPENDoption, Progress creates the target file anew (which overwrites the original file).If
target-filenameresolves to the Unknown value (?), or the target file cannot be created or written, Progress raises the ERROR condition.NO-CONVERT | CONVERTconvert-phraseLets you specify the character conversion behavior between the source and target objects.
The
NO-CONVERToption specifies that no conversions occur. However, if the target is a LONGCHAR or a CLOB, Progress validates the character data based on the target object’s code page. For a CLOB, this is the code page of the CLOB. For a LONGCHAR, this is-cpinternalunless the LONGCHAR’s code page was set using the FIX-CODEPAGE function. If the validation fails, Progress raises the ERROR condition.The
CONVERToption lets you specify how Progress converts object data. Following is the syntax forconvert-phrase:
Specify
SOURCECODEPAGEto indicate that a source object is in the specified code page. If you specifyTARGETCODEPAGE, Progress converts the target object to the specified code page.Table 17 lists the default character conversions Progress performs when copying data between the source and target objects. References to CLOBCP and CLOBDB represent CLOB data in either the CLOB’s defined code page or the database's defined code page, respectively. References to the "fixed code page" represent the code page of a target LONGCHAR variable set using the FIX-CODEPAGE function.
Note: If either the source or target object is a file, the target’s code page defaults to-cpstream.NO-ERRORSuppresses any errors that occur as a result of the copy operation. After the statement completes, you can check the ERROR-STATUS system handle for information about any errors that might have occurred.
Notes
- If a source or target object is stored in a database, its record must be available to copy. The lock mode of the record containing the target object must be EXCLUSIVE-LOCK or SHARE-LOCK and upgradeable; otherwise, the COPY-LOB statement raises the ERROR condition.
- You can also assign large object data from one BLOB or MEMPTR to another, and one CLOB or LONGCHAR to another, using the = Assignment operator or ASSIGN statement. You cannot use the = Assignment operator or ASSIGN statement to assign large object data between BLOBs or MEMPTRs and CLOBs or LONGCHARs.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |